package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.ColumnsRef;

/**
 * 
 * @author 
 *
 */
@DAO
public interface ColumnsRefDAO{
	
	@SQL("select group_concat(b.descs) as descs from ColumnsRef a left JOIN RoleInfo b on a.roleId=b.id where a.columnsId=:1")
	List<String> query(int columnsId);
	
	@SQL("select group_concat(roleId) as roleId from ColumnsRef where columnsId=:1")
	String queryRoleByColumnsId(int columnsId);
	
    @SQL("INSERT INTO ColumnsRef (roleId,columnsId,deleteFlag) VALUES (:t.roleId,:t.columnsId,1)")
    void create(@SQLParam("t") ColumnsRef columnsRef);
	
	@SQL("UPDATE ColumnsRef SET roleId=:t.roleId,columnsId=:t.columnsId WHERE id=:t.id")
    void update(@SQLParam("t") ColumnsRef columnsRef);
    
    @SQL("delete from ColumnsRef WHERE columnsId=:1")
    void deleteById(int columnsId);
}